while true
do
    if [ -d "merged" ]; then
        rm -rf internlm2-chat-7b
        cp -r sales-chat-7b internlm2-chat-7b
        cp -r merged/* internlm2-chat-7b/
        cd internlm2-chat-7b
        git lfs install
        git add .
        git commit -m "智能营销助手"
        git push --force
        cd ..
        rm -rf work_dirs hf merged
    fi

    xtuner train ./internlm2_chat_7b_qlora_sales_e3.py

    pth_file=`ls -rt work_dirs/internlm2_chat_7b_qlora_sales_e3/*.pth | tail -n 1`

    mkdir hf
    export MKL_SERVICE_FORCE_INTEL=1
    export MKL_THREADING_LAYER=GNU
    xtuner convert pth_to_hf ./internlm2_chat_7b_qlora_sales_e3.py ./${pth_file} ./hf

    xtuner convert merge ./internlm2-chat-7b ./hf ./merged --max-shard-size 2GB

    if [ -d "merged" ]; then
        rm -rf internlm2-chat-7b
        cp -r sales-chat-7b internlm2-chat-7b
        cp -r merged/* internlm2-chat-7b/
        cd internlm2-chat-7b
        git lfs install
        git add .
        git commit -m "智能营销助手"
        git push --force
        cd ..
        rm -rf work_dirs hf merged
    fi
done